<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:ry="">
	<head>
		<th:block th:include="include :: header('修改生成信息')" />
		<th:block th:include="include :: select2-css" />
		<style type="text/css">
		    .select-table table{table-layout:fixed;}.table>thead>tr>th{text-align:center;}.select-table .table td{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.form-control{padding:3px 6px 4px;height:30px;}.icheckbox-blue{top:0px;left:6px;}.form-control.select2-hidden-accessible{position:static!important;}.select-table table label.error{position: inherit;}select + label.error{z-index:1;right:40px;}
            .select2-container--bootstrap .select2-selection {
                font-size: 12px;
            }
            li.select2-results__option {
                font-size: 12px;
            }
        </style>
	</head>
	<body class="gray-bg" style="font: 14px Helvetica Neue, Helvetica, PingFang SC, 微软雅黑, Tahoma, Arial, sans-serif !important;">
	    <div class="row">
	        <div class="col-xs-12">
	            <div class="ibox float-e-margins">
	                <div class="ibox-content" style="border-style:none;padding: 15px 20px 0px 20px;">
	                    <div class="nav-tabs-custom">
	                        <ul class="nav nav-tabs">
	                            <li class="active"><a href="#tab-basic" data-toggle="tab" aria-expanded="false">基本信息</a></li>
	                            <li><a href="#tab-field" data-toggle="tab" aria-expanded="true">字段信息</a></li>
	                        </ul>
	                        <form id="form-gen-edit" class="form-horizontal">
		                        <input name="table_id" type="hidden" th:value="${table.tableId}" />
		                        <div class="tab-content">
		                            <!-- 基本信息 -->
		                            <div class="tab-pane active" id="tab-basic">
							            <div class="row mt20">
							            	<div class="col-sm-6">
							                    <div class="form-group">
							                        <label class="col-sm-4 control-label"><span style="color: red; ">*</span>表名称：</label>
							                        <div class="col-sm-8">
							                            <input name="table_name" class="form-control" type="text" placeholder="请输入表名称" maxlength="200" th:value="${table.tableName}" required>
							                        </div>
							                    </div>
							                </div>
							                <div class="col-sm-6">
							                    <div class="form-group">
							                        <label class="col-sm-4 control-label"><span style="color: red; ">*</span>表描述：</label>
							                        <div class="col-sm-8">
							                            <input name="table_comment" class="form-control" type="text" placeholder="请输入表描述" maxlength="500" th:value="${table.tableComment}" required>
							                        </div>
							                    </div>
							                </div>
							            </div>
							            <div class="row">
							                <div class="col-sm-6">
							                    <div class="form-group">
							                        <label class="col-sm-4 control-label"><span style="color: red; ">*</span>实体类名称：</label>
							                        <div class="col-sm-8">
							                            <input name="class_name" class="form-control" type="text" placeholder="请输入实体类名称" maxlength="100" th:value="${table.className}" required>
							                        </div>
							                    </div>
							                </div>
							                <div class="col-sm-6">
							                    <div class="form-group">
							                        <label class="col-sm-4 control-label"><span style="color: red; ">*</span>作者：</label>
							                        <div class="col-sm-8">
							                            <input name="function_author" class="form-control" type="text" placeholder="请输入作者" maxlength="50" th:value="${table.functionAuthor}" required>
							                        </div>
							                    </div>
							                </div>
							            </div>
							            <div class="row">
							                <div class="col-sm-12">
							                    <div class="form-group">
							                        <label class="col-xs-2 control-label">备注：</label>
							                        <div class="col-xs-10">
							                            <textarea name="remark" maxlength="500" class="form-control" rows="3">[[${table.remark}]]</textarea>
							                        </div>
							                    </div>
							                </div>
							            </div>

							            <h4 class="form-header h4">生成信息</h4>
							            <div class="row">
							                <div class="col-sm-6">
							                    <div class="form-group">
							                        <label class="col-sm-4 control-label"><span style="color: red; ">*</span>生成模板：</label>
							                        <div class="col-sm-8">
							                            <select class='form-control' id="tpl_category" name='tpl_category' style="width: 100%">
														    <option value="crud" th:field="${table.tplCategory}">单表（增删改查）</option>
														    <option value="tree" th:field="${table.tplCategory}">树表（增删改查）</option>
														</select>
							                        </div>
							                    </div>
							                </div>
							                <div class="col-sm-6">
							                    <div class="form-group">
							                        <label class="col-sm-4 control-label" title="生成在哪个java包下，例如 com.ruoyi.project.system">
							                        	<span style="color: red; ">*</span>生成包路径：<i class="fa fa-question-circle-o"></i>
							                        </label>
							                        <div class="col-sm-8">
							                            <input name="package_name" class="form-control" type="text" placeholder="请输入生成包路径" maxlength="100" th:value="${table.packageName}" required>
							                        </div>
							                    </div>
							                </div>
							            </div>
							            <div class="row">
							                <div class="col-sm-6">
							                    <div class="form-group">
							                        <label class="col-sm-4 control-label" title="可理解为子系统名，例如 system"><span style="color: red; ">*</span>生成模块名：<i class="fa fa-question-circle-o"></i></label>
							                        <div class="col-sm-8">
							                            <input name="module_name" class="form-control" type="text" placeholder="请输入生成模块名" maxlength="30" th:value="${table.moduleName}" required>
							                        </div>
							                    </div>
							                </div>
							                <div class="col-sm-6">
							                    <div class="form-group">
							                        <label class="col-sm-4 control-label" title="可理解为功能英文名，例如 user"><span style="color: red; ">*</span>生成业务名：<i class="fa fa-question-circle-o"></i></label>
							                        <div class="col-sm-8">
							                            <input name="business_name" class="form-control" type="text" placeholder="请输入生成业务名" maxlength="50" th:value="${table.businessName}" required>
							                        </div>
							                    </div>
							                </div>
							            </div>

							            <div class="row">
							                <div class="col-sm-6">
							                    <div class="form-group">
							                        <label class="col-sm-4 control-label" title="用作类描述，例如 用户"><span style="color: red; ">*</span>生成功能名：<i class="fa fa-question-circle-o"></i></label>
							                        <div class="col-sm-8">
							                            <input name="function_name" class="form-control" type="text" placeholder="请输入生成功能名" maxlength="50" th:value="${table.functionName}" required>
							                        </div>
							                    </div>
							                </div>
							            </div>

                                        <div class="row">
                                            <div class="col-sm-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label" title="默认为zip压缩包下载，也可以自定义生成路径">生成代码方式：<i class="fa fa-question-circle-o"></i></label>
                                                    <div class="col-sm-8">
                                                        <ry:radio name="gen_type" class="radio-box" itemLabel="zip压缩包" itemValue="0" th:value="${table.genType}"/>
                                                        <ry:radio name="gen_type" class="radio-box" itemLabel="自定义路径" itemValue="1" th:value="${table.genType}"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="hidden row" id="pathinfo">
                                            <div class="col-sm-12">
                                                <div class="form-group">
                                                    <label class="col-xs-2 control-label" title="填写磁盘绝对路径，若不填写，则生成到当前Web项目下">生成基础路径：<i class="fa fa-question-circle-o"></i></label>
                                                    <div class="col-xs-10">
                                                        <div class="input-group input-group-sm">
                                                            <input id="gen_path" name="gen_path" class="form-control" type="text" th:value="${table.genPath}" placeholder="请输入项目路径" maxlength="200"/>
                                                            <div class="input-group-btn">
                                                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">最近路径快速选择 <span class="caret"></span></button>
                                                                <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                                                    <li><a href="javascript:$('#gen_path').val('/')"><i class="fa fa-refresh"></i>恢复默认的生成基础路径</a></li>
                                                                </ul>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

							            <div class="hidden" id="otherInfo">
								            <h4 class="form-header h4">其他信息</h4>
								            <div class="row">
								                <div class="col-sm-6">
								                    <div class="form-group">
								                        <label class="col-sm-4 control-label" title="树显示的编码字段名， 如：dept_id"><span style="color: red; ">*</span>树编码字段：<i class="fa fa-question-circle-o"></i></label>
								                        <div class="col-sm-8">
								                            <select class='form-control' id="treeCode" name='treeCode' style="width: 100%">
								                                <option value="">---请选择---</option>
															    <option th:each="column : ${table.columns}" th:text="${column.columnName + '：' + column.columnComment}" th:value="${column.columnName}" th:field="${table.treeCode}"></option>
															</select>
								                        </div>
								                    </div>
								                </div>
								                <div class="col-sm-6">
								                    <div class="form-group">
								                        <label class="col-sm-4 control-label" title="树显示的父编码字段名， 如：parent_Id"><span style="color: red; ">*</span>树父编码字段：<i class="fa fa-question-circle-o"></i></label>
								                        <div class="col-sm-8">
								                            <select class='form-control' id="treeParentCode" name='treeParentCode' style="width: 100%">
															    <option value="">---请选择---</option>
															    <option th:each="column : ${table.columns}" th:text="${column.columnName + '：' + column.columnComment}" th:value="${column.columnName}" th:field="${table.treeParentCode}"></option>
															</select>
								                        </div>
								                    </div>
								                </div>
								            </div>
								            <div class="row">
								                <div class="col-sm-6">
								                    <div class="form-group">
								                        <label class="col-sm-4 control-label" title="树节点的显示名称字段名， 如：dept_name"><span style="color: red; ">*</span>树名称字段：<i class="fa fa-question-circle-o"></i></label>
								                        <div class="col-sm-8">
								                            <select class='form-control' id="treeName" name='treeName' style="width: 100%">
															    <option value="">---请选择---</option>
															    <option th:each="column : ${table.columns}" th:text="${column.columnName + '：' + column.columnComment}" th:value="${column.columnName}" th:field="${table.treeName}"></option>
															</select>
								                        </div>
								                    </div>
								                </div>
								            </div>
							            </div>
		                            </div>

		                            <!-- 字段信息 -->
		                            <div class="tab-pane" id="tab-field">
		                                <div class="select-table table-striped" style="margin-top: 0px;padding: 5px;">
										    <table class="table table-hover" style="font-size: 12px;">
												<thead>
													<tr>
														<th>字段列名</th>
														<th><font color="red">*</font>字段描述</th>
														<th style="width: 100px;">物理类型</th>
														<th style="width: 100px;"><font color="red">*</font>Java类型</th>
														<th style="display: none;"><font color="red">*</font>Java属性</th>
														<th style="width: 45px;">新增</th>
														<th style="width: 45px;">修改</th>
														<th style="width: 45px;">列表</th>
														<th style="width: 45px;">查询</th>
                                                        <th style="width: 45px;">导出</th>
														<th style="width: 100px;">查询方式</th>
														<th style="width: 45px;">必填</th>
														<th style="width: 100px;">显示类型</th>
														<th style="width: 80px;">字典类型</th>
														<th style="width: 50px;"><font color="red">*</font>排序</th>
													</tr>
												</thead>
												<tbody>
													<tr th:each="column : ${table.columns}" >
														<td align="center">
															<input type="hidden" name="column_id" th:value="${column.columnId}" />
															[[${column.columnName}]]
														</td>
														<td align="center">
															<input class="form-control" type="text" name="column_comment" th:value="${column.columnComment}" style="width: 99%;font-size: 12px;" required/>
														</td>
														<td align="center">
															[[${column.columnType}]]
														</td>
														<td align="center">
															<select class='form-control' name='java_type' style="font-size: 12px;">
															    <option value="Long" th:selected="${column.javaType == 'Long'}">Long</option>
															    <option value="String" th:selected="${column.javaType == 'String'}">String</option>
															    <option value="Integer" th:selected="${column.javaType == 'Integer'}">Integer</option>
															    <option value="Double" th:selected="${column.javaType == 'Double'}">Double</option>
															    <option value="BigDecimal" th:selected="${column.javaType == 'BigDecimal'}">BigDecimal</option>
															    <option value="Date" th:selected="${column.javaType == 'Date'}">Date</option>
															</select>
														</td>
														<td align="center" style="display: none;">
															<input class="form-control" type="text" name="java_field" th:value="${column.javaField}" style="width: 99%;font-size: 12px;" required/>
														</td>
														<td align="center">
                                                            <input type='checkbox' th:checked="${column.isInsert == '1'}" onclick="clickCheckBox(this);"/>
                                                            <input type="hidden" name="is_insert" th:value="${column.isInsert}" />
														</td>
														<td align="center">
                                                            <input type='checkbox' th:checked="${column.isEdit == '1'}" onclick="clickCheckBox(this);"/>
                                                            <input type="hidden" name="is_edit" th:value="${column.isEdit}" />
														</td>
														<td align="center">
                                                            <input type='checkbox' th:checked="${column.isList == '1'}" onclick="clickCheckBox(this);"/>
                                                            <input type="hidden" name="is_list" th:value="${column.isList}" />
														</td>
														<td align="center">
                                                            <input type='checkbox' th:checked="${column.isQuery == '1'}" onclick="clickCheckBox(this);"/>
                                                            <input type="hidden" name="is_query" th:value="${column.isQuery}" />
														</td>
                                                        <td align="center">
                                                            <input type='checkbox' th:checked="${column.isExport == '1'}" onclick="clickCheckBox(this);"/>
                                                            <input type="hidden" name="is_export" th:value="${column.isExport}" />
                                                        </td>
														<td align="center">
															<select class='form-control' name='query_type'>
															    <option value="EQ" th:selected="${column.queryType == 'EQ'}">=</option>
															    <option value="NE" th:selected="${column.queryType == 'NE'}">!=</option>
															    <option value="GT" th:selected="${column.queryType == 'GT'}">&gt;</option>
															    <option value="GTE" th:selected="${column.queryType == 'GTE'}">&ge;</option>
															    <option value="LT" th:selected="${column.queryType == 'LT'}">&lt;</option>
															    <option value="LTE" th:selected="${column.queryType == 'LTE'}">&le;</option>
															    <option value="LIKE" th:selected="${column.queryType == 'LIKE'}">Like</option>
															    <option value="BETWEEN" th:selected="${column.queryType == 'BETWEEN'}">Between</option>
															</select>
														</td>
														<td align="center">
															<input type='checkbox' th:checked="${column.isRequired == '1'}" onclick="clickCheckBox(this);"/>
															<input type="hidden" name="is_required" th:value="${column.isRequired}" />
														</td>
														<td align="center">
															<select class='form-control' name='html_type'>
															    <option value="input" th:selected="${column.htmlType == 'input'}">文本框</option>
															    <option value="textarea" th:selected="${column.htmlType == 'textarea'}">文本域</option>
															    <option value="select" th:selected="${column.htmlType == 'select'}">下拉框</option>
															    <option value="radio" th:selected="${column.htmlType == 'radio'}">单选框</option>
															    <option value="checkbox" th:selected="${column.htmlType == 'checkbox'}">复选框</option>
                                                                <option value="summernote" th:selected="${column.htmlType == 'summernote'}">富文本域</option>
															    <option value="datetime" th:selected="${column.htmlType == 'datetime'}">日期控件</option>
                                                                <option value="upload" th:selected="${column.htmlType == 'upload'}">上传控件</option>
															</select>
														</td>
														<td align="center">
															<input class="form-control" type="text" name="dict_type" th:value="${column.dictType}" th:id="'columns_dict_'+${column.columnId}"
																style="width: 99%;font-size: 12px;" th:onclick="'selectDictTree('+${column.columnId}+', this)'"/>
														</td>
														<td align="center">
															<input class="form-control" type="text" name="sort" th:value="${column.sort}" style="width: 99%;font-size: 12px;" required/>
														</td>
													</tr>
												</tbody>
											</table>
										</div>
		                            </div>
		                        </div>
	                        </form>
	                    </div>
	                </div>
	               <div class="box-footer" style="margin-bottom: 10px;">
				       <div class="col-sm-offset-5 col-sm-6">
				           <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
				           <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
				       </div>
	           	   </div>
	            </div>
	        </div>
	    </div>

	    <th:block th:include="include :: footer" />
	    <th:block th:include="include :: select2-js" />
	    <th:block th:include="include :: bootstrap-table-reorder-js" />
	    <script th:src="@{/js/jquery.tmpl.js}"></script>
	    <script type="text/javascript">
		    $("#form-table-edit").validate({
		    	rules: {
		    	    table_name: {
		    	        required: true,
		    	    },
		    	},
				focusCleanup: true
			});

		    function submitHandler() {
		        $.operate.saveTab(ctx + "tool/gen/edit", $("#form-gen-edit").serializeArray());
		    }

		    function clickCheckBox(src) {
				var checked = $(src).prop("checked");
				if(checked) {
					$(src).next().val("1");
				}
				else {
					$(src).next().val("0");
				}
		    }

			$(function() {
	            var tplCategory = $("#tpl_category option:selected").val();
	            tplCategoryVisible(tplCategory);
                var genType = $('input[name="gen_type"]:checked').val();
                pathInfoVisible(genType);
	        });

			$('#tpl_category').on('select2:select', function (event) {
				var tplCategory = $(event.target).val();
				tplCategoryVisible(tplCategory);
			});

			function tplCategoryVisible(tplCategory) {
				if("crud" == tplCategory){
					$("#treeCode").select2("val", [""]);
					$("#treeParentCode").select2("val", [""]);
					$("#treeName").select2("val", [""]);
					$("#otherInfo").addClass("hidden");

				} else if("tree" == tplCategory){
					$("#otherInfo").removeClass("hidden");
					$("#treeCode").attr("required", "true");
					$("#treeParentCode").attr("required", "true");
					$("#treeName").attr("required", "true");
				}
	        }

            $('input').on('ifChecked', function(event){
                var genType = $(event.target).val();
                pathInfoVisible(genType);
            });

            function pathInfoVisible(genType) {
                if("0" == genType){
                    $("#genPath").val("/");
                    $("#pathinfo").addClass("hidden");
                } else if("1" == genType){
                    $("#pathinfo").removeClass("hidden");
                }
            }

			//选择字典处理函数
			function selectDictTree(columnId, obj) {
				var dictType = $.common.nullToStr($(obj).parent().find("input").val());
	        	var url = ctx + "system/dict/selectDictTree/" + columnId + "/" + dictType;
				var options = {
					title: '选择字典类型',
					width: "380",
					url: url,
					callBack: doSubmit
				};
				$.modal.openOptions(options);
			}

			function doSubmit(index, layero){
				var body = layer.getChildFrame('body', index);
	   			var columnId = body.find('#columnId').val();
	   			var dictType = body.find('#dict_type').val();
	   			layer.close(index);
	   			$("#columns_dict_" + columnId).val(dictType);
			}
	    </script>
	</body>
</html>